<html>
<head><meta charset="utf-8"><title>REPL: dyn Debug intrinsic · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html">REPL: dyn Debug intrinsic</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="182187913"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182187913" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182187913">(Nov 29 2019 at 15:58)</a>:</h4>
<p>What does the intrinsic do exactly? create a dummy vtable printing nothing or a default value if there's no <code>Debug</code> impl?</p>



<a name="182188132"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182188132" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182188132">(Nov 29 2019 at 16:01)</a>:</h4>
<p>context: <a href="https://hackmd.io/GJokfI0wQ0i4SIgRbFTmfw" target="_blank" title="https://hackmd.io/GJokfI0wQ0i4SIgRbFTmfw">https://hackmd.io/GJokfI0wQ0i4SIgRbFTmfw</a></p>



<a name="182188507"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182188507" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182188507">(Nov 29 2019 at 16:06)</a>:</h4>
<p>right, let me paste my code from the REPL repo</p>



<a name="182188606"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182188606" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182188606">(Nov 29 2019 at 16:08)</a>:</h4>
<p>This is the handling of the new intrinsic, in the match stmt in <code>call_intrinsic</code>:</p>
<div class="codehilite"><pre><span></span><span class="w">            </span><span class="s">&quot;as_debug&quot;</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">                </span><span class="kd">let</span><span class="w"> </span><span class="n">existential_trait_ref</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">match</span><span class="w"> </span><span class="n">dest</span><span class="p">.</span><span class="n">layout</span><span class="p">.</span><span class="n">ty</span><span class="p">.</span><span class="n">sty</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">                    </span><span class="n">ty</span>::<span class="n">RawPtr</span><span class="p">(</span><span class="n">tm</span><span class="p">)</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">                        </span><span class="k">match</span><span class="w"> </span><span class="n">tm</span><span class="p">.</span><span class="n">ty</span><span class="p">.</span><span class="n">sty</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">                            </span><span class="n">ty</span>::<span class="n">Dynamic</span><span class="p">(</span><span class="k">ref</span><span class="w"> </span><span class="n">data</span><span class="p">,</span><span class="w"> </span><span class="n">_</span><span class="p">)</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"></span>
<span class="w">                                </span><span class="n">data</span><span class="p">.</span><span class="n">principal</span><span class="p">()</span><span class="w"></span>
<span class="w">                                    </span><span class="p">.</span><span class="n">expect</span><span class="p">(</span><span class="s">&quot;&#39;debug trait&#39; has no principal trait&quot;</span><span class="p">),</span><span class="w"></span>
<span class="w">                            </span><span class="n">_</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="n">panic</span><span class="o">!</span><span class="p">(</span><span class="s">&quot;return type pointee is not dynamic type&quot;</span><span class="p">),</span><span class="w"></span>
<span class="w">                        </span><span class="p">}</span><span class="w"></span>
<span class="w">                    </span><span class="p">}</span><span class="w"></span>
<span class="w">                    </span><span class="n">_</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="n">panic</span><span class="o">!</span><span class="p">(</span><span class="s">&quot;return type is not raw pointer&quot;</span><span class="p">),</span><span class="w"></span>
<span class="w">                </span><span class="p">};</span><span class="w"></span>

<span class="w">                </span><span class="kd">let</span><span class="w"> </span><span class="n">pointee_ty</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">substs</span><span class="p">.</span><span class="n">type_at</span><span class="p">(</span><span class="mi">0</span><span class="p">);</span><span class="w"></span>
<span class="w">                </span><span class="kd">let</span><span class="w"> </span><span class="n">trait_predicate</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">existential_trait_ref</span><span class="p">.</span><span class="n">with_self_ty</span><span class="p">(</span><span class="o">*</span><span class="n">tcx</span><span class="p">,</span><span class="w"> </span><span class="n">pointee_ty</span><span class="p">).</span><span class="n">to_predicate</span><span class="p">();</span><span class="w"></span>
<span class="w">                </span><span class="kd">let</span><span class="w"> </span><span class="n">val</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">evaluate_predicate</span><span class="p">(</span><span class="n">tcx</span><span class="p">,</span><span class="w"> </span><span class="n">instance</span><span class="p">,</span><span class="w"> </span><span class="n">trait_predicate</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">                    </span><span class="kd">let</span><span class="w"> </span><span class="n">ptr</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">this</span><span class="p">.</span><span class="n">read_immediate</span><span class="p">(</span><span class="n">args</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span><span class="o">?</span><span class="p">.</span><span class="n">to_scalar_ptr</span><span class="p">()</span><span class="o">?</span><span class="p">;</span><span class="w"></span>
<span class="w">                    </span><span class="kd">let</span><span class="w"> </span><span class="n">vtable</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">this</span><span class="p">.</span><span class="n">get_vtable</span><span class="p">(</span><span class="n">pointee_ty</span><span class="p">,</span><span class="w"> </span><span class="nb">Some</span><span class="p">(</span><span class="n">existential_trait_ref</span><span class="p">))</span><span class="o">?</span><span class="p">;</span><span class="w"></span>
<span class="w">                    </span><span class="n">Immediate</span>::<span class="n">new_dyn_trait</span><span class="p">(</span><span class="n">ptr</span><span class="p">,</span><span class="w"> </span><span class="n">vtable</span><span class="p">)</span><span class="w"></span>
<span class="w">                </span><span class="p">}</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">                    </span><span class="kd">let</span><span class="w"> </span><span class="n">vtable</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">this</span><span class="p">.</span><span class="n">get_vtable</span><span class="p">(</span><span class="n">pointee_ty</span><span class="p">,</span><span class="w"> </span><span class="nb">None</span><span class="p">)</span><span class="o">?</span><span class="p">;</span><span class="w"></span>
<span class="w">                    </span><span class="n">Immediate</span>::<span class="n">new_dyn_trait</span><span class="p">(</span><span class="n">Scalar</span>::<span class="n">ptr_null</span><span class="p">(</span><span class="n">this</span><span class="p">),</span><span class="w"> </span><span class="n">vtable</span><span class="p">)</span><span class="w"></span>
<span class="w">                </span><span class="p">};</span><span class="w"></span>
<span class="w">                </span><span class="n">this</span><span class="p">.</span><span class="n">write_immediate</span><span class="p">(</span><span class="n">val</span><span class="p">,</span><span class="w"> </span><span class="n">dest</span><span class="p">)</span><span class="o">?</span><span class="p">;</span><span class="w"></span>
<span class="w">            </span><span class="p">}</span><span class="w"></span>
</pre></div>



<a name="182188617"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182188617" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182188617">(Nov 29 2019 at 16:08)</a>:</h4>
<p>and a helper fn:</p>
<div class="codehilite"><pre><span></span><span class="k">fn</span> <span class="nf">evaluate_predicate</span><span class="o">&lt;</span><span class="na">&#39;tcx</span><span class="o">&gt;</span><span class="p">(</span><span class="w"></span>
<span class="w">    </span><span class="n">tcx</span>: <span class="kp">&amp;</span><span class="nc">TyCtxt</span><span class="o">&lt;</span><span class="na">&#39;tcx</span><span class="o">&gt;</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="n">instance</span>: <span class="nc">Instance</span><span class="o">&lt;</span><span class="na">&#39;tcx</span><span class="o">&gt;</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="n">predicate</span>: <span class="nc">Predicate</span><span class="o">&lt;</span><span class="na">&#39;tcx</span><span class="o">&gt;</span><span class="p">,</span><span class="w"></span>
<span class="p">)</span><span class="w"> </span>-&gt; <span class="kt">bool</span> <span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="c1">// FIXME: is this really necessary? Maybe we can just use `DUMMY_HIR_ID` instead.</span>
<span class="w">    </span><span class="c1">// Or use `Obligation::new` and `ObligationCause::dummy`?</span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">body_id</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">tcx</span><span class="p">.</span><span class="n">hir</span><span class="p">().</span><span class="n">as_local_hir_id</span><span class="p">(</span><span class="n">instance</span><span class="p">.</span><span class="n">def_id</span><span class="p">())</span><span class="w"></span>
<span class="w">        </span><span class="p">.</span><span class="n">expect</span><span class="p">(</span><span class="s">&quot;`instance` is not in local crate&quot;</span><span class="p">);</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">obligation</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">Obligation</span>::<span class="n">misc</span><span class="p">(</span><span class="n">DUMMY_SP</span><span class="p">,</span><span class="w"> </span><span class="n">body_id</span><span class="p">,</span><span class="w"> </span><span class="n">ParamEnv</span>::<span class="n">reveal_all</span><span class="p">(),</span><span class="w"> </span><span class="n">predicate</span><span class="p">);</span><span class="w"></span>
<span class="w">    </span><span class="n">tcx</span><span class="p">.</span><span class="n">infer_ctxt</span><span class="p">().</span><span class="n">enter</span><span class="p">(</span><span class="o">|</span><span class="n">infer_ctxt</span><span class="o">|</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="k">match</span><span class="w"> </span><span class="n">infer_ctxt</span><span class="p">.</span><span class="n">evaluate_obligation</span><span class="p">(</span><span class="o">&amp;</span><span class="n">obligation</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">            </span><span class="nb">Ok</span><span class="p">(</span><span class="n">EvaluationResult</span>::<span class="n">EvaluatedToOk</span><span class="p">)</span><span class="w"> </span><span class="o">|</span><span class="w"></span>
<span class="w">            </span><span class="nb">Ok</span><span class="p">(</span><span class="n">EvaluationResult</span>::<span class="n">EvaluatedToOkModuloRegions</span><span class="p">)</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="kc">true</span><span class="p">,</span><span class="w"></span>
<span class="w">            </span><span class="nb">Ok</span><span class="p">(</span><span class="n">_</span><span class="p">)</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="kc">false</span><span class="p">,</span><span class="w"></span>
<span class="w">            </span><span class="nb">Err</span><span class="p">(</span><span class="n">_</span><span class="p">)</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="kc">false</span><span class="p">,</span><span class="w"></span>
<span class="w">        </span><span class="p">}</span><span class="w"></span>
<span class="w">    </span><span class="p">})</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>



<a name="182188717"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182188717" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182188717">(Nov 29 2019 at 16:10)</a>:</h4>
<p>alternatively (as I believe I mentioned in the design doc), the intrinsic could save the debug representation to a field in the <code>Evaluator</code>, and let the REPL do the printing of its own accord.</p>



<a name="182188747"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182188747" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182188747">(Nov 29 2019 at 16:10)</a>:</h4>
<p>this might make (e.g.) formatted/coloured printing, depending on settings of the REPL, a bit easier.</p>



<a name="182188750"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182188750" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182188750">(Nov 29 2019 at 16:10)</a>:</h4>
<p>obviously a minor point though.</p>



<a name="182188860"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182188860" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182188860">(Nov 29 2019 at 16:12)</a>:</h4>
<p>so... what debug impl is being used in case there is no debug impl?</p>



<a name="182188870"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182188870" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182188870">(Nov 29 2019 at 16:12)</a>:</h4>
<p>the pointer to the data is printed?</p>



<a name="182188882"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182188882" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182188882">(Nov 29 2019 at 16:12)</a>:</h4>
<p>no, it looks like a null ponter, but I don't get what the vtable is</p>



<a name="182188918"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182188918" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182188918">(Nov 29 2019 at 16:13)</a>:</h4>
<p>sadly specialization doesn't work for this case it seems, otherwise we could use <a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=faaa84ebb20225679401d0c7cc108149" target="_blank" title="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=faaa84ebb20225679401d0c7cc108149">https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=faaa84ebb20225679401d0c7cc108149</a></p>



<a name="182189000"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182189000" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182189000">(Nov 29 2019 at 16:14)</a>:</h4>
<p>yes, indeed. I experimented with that before trying this.</p>



<a name="182189042"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182189042" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182189042">(Nov 29 2019 at 16:15)</a>:</h4>
<p>so, right now, the <code>main fn</code> (template) looks like this:</p>
<div class="codehilite"><pre><span></span><span class="w">    </span><span class="k">fn</span> <span class="nf">main</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="n">user_body</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="cp">#[rustc_interp_user_fn]</span><span class="w"> </span><span class="o">||</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">user_body_placeholder</span><span class="w"> </span><span class="p">};</span><span class="w"></span>

<span class="w">        </span><span class="cp">#[allow(unused)]</span><span class="w"></span>
<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="n">ret</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">user_body</span><span class="p">();</span><span class="w"></span>
<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="n">debug</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">as_debug</span><span class="p">(</span><span class="o">&amp;</span><span class="n">ret</span><span class="p">);</span><span class="w"></span>
<span class="w">        </span><span class="k">if</span><span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nb">Some</span><span class="p">(</span><span class="n">debug</span><span class="p">)</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">debug</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">            </span><span class="n">println</span><span class="o">!</span><span class="p">(</span><span class="s">&quot;{:?}&quot;</span><span class="p">,</span><span class="w"> </span><span class="n">debug</span><span class="p">);</span><span class="w"></span>
<span class="w">        </span><span class="p">}</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">            </span><span class="n">println</span><span class="o">!</span><span class="p">(</span><span class="s">&quot;[{}]&quot;</span><span class="p">,</span><span class="w"> </span><span class="n">type_name</span><span class="p">(</span><span class="o">&amp;</span><span class="n">ret</span><span class="p">));</span><span class="w"></span>
<span class="w">        </span><span class="p">}</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
</pre></div>



<a name="182189105"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182189105" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182189105">(Nov 29 2019 at 16:16)</a>:</h4>
<p>oh, the <code>null</code> turns into <code>None</code> <span aria-label="upside down" class="emoji emoji-1f643" role="img" title="upside down">:upside_down:</span> ok</p>



<a name="182189110"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182189110" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182189110">(Nov 29 2019 at 16:16)</a>:</h4>
<p>yep heh</p>



<a name="182189125"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182189125" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182189125">(Nov 29 2019 at 16:16)</a>:</h4>
<p>seems good to me, but needs a lot of comments so future readers get all that</p>



<a name="182189172"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182189172" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182189172">(Nov 29 2019 at 16:17)</a>:</h4>
<p>I will change <code>user_body_placeholder</code> to be a macro call however, and do the pre-parsing of the whole template in the REPL itself (with an even more minor extension to the <code>Parser</code> interface than present), which I think people prefer.</p>



<a name="182189176"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182189176" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182189176">(Nov 29 2019 at 16:17)</a>:</h4>
<p>yeah, no problem. more comments is understandable.</p>



<a name="182189761"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182189761" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182189761">(Nov 29 2019 at 16:28)</a>:</h4>
<p>anyway, thanks for giving the nod to a lot of this REPL design stuff and helping to move it along, in spite of our differences on some matters. I will r? you (or RalfJung, I guess) on the mir/mir-interpreter-related rustc PR when the time arises, if that's alright.</p>



<a name="182189863"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182189863" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182189863">(Nov 29 2019 at 16:30)</a>:</h4>
<p>yea, as always, please only add functional changes to the PRs and make one PR per "topic" (e.g. one for Machine changes, one for command line flag + new attributes). We'll be able to move along much faster with individual PRs</p>



<a name="182189868"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182189868" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182189868">(Nov 29 2019 at 16:30)</a>:</h4>
<p>will do</p>



<a name="182189879"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182189879" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182189879">(Nov 29 2019 at 16:30)</a>:</h4>
<p>Thanks!</p>



<a name="182189936"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182189936" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182189936">(Nov 29 2019 at 16:32)</a>:</h4>
<p>if there are any formatting changes or changes to comments, I'll make sure they're only <em>clear improvements</em> that are directly next to functional changes. and they shan't be many. I will have a pass over my existing PRs to remove extraneous "cosmetic" stuff, but if I forget, just let me know matter-of-factly, because it will probably be that I've simply overlooked them. :-)</p>



<a name="182190004"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182190004" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182190004">(Nov 29 2019 at 16:32)</a>:</h4>
<p>sgtm</p>



<a name="182190038"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182190038" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182190038">(Nov 29 2019 at 16:33)</a>:</h4>
<p>;-)</p>



<a name="182190109"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182190109" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182190109">(Nov 29 2019 at 16:34)</a>:</h4>
<p>don't worry: I've just gotten this design doc essentially approved. the last thing I want to do is annoy reviewers or make getting PRs approved a pain for all of us!</p>



<a name="182235780"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182235780" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nadrieril <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182235780">(Nov 30 2019 at 11:36)</a>:</h4>
<blockquote>
<p>sadly specialization doesn't work for this case it seems, otherwise we could use <a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=faaa84ebb20225679401d0c7cc108149" target="_blank" title="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=faaa84ebb20225679401d0c7cc108149">https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=faaa84ebb20225679401d0c7cc108149</a></p>
</blockquote>
<p>Does it not ? I think you just omitted a <code>default</code> <a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=bc90cd6d61e11d07cd9b3517bdf38940" target="_blank" title="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=bc90cd6d61e11d07cd9b3517bdf38940">https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=bc90cd6d61e11d07cd9b3517bdf38940</a></p>



<a name="182236745"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182236745" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182236745">(Nov 30 2019 at 12:04)</a>:</h4>
<p>Awesome, you don't even need the DebugEverything trait since it's implemented for all types. <a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=83de0447fe2d0bc2eda7fc27c5437dcc" target="_blank" title="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=83de0447fe2d0bc2eda7fc27c5437dcc">https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=83de0447fe2d0bc2eda7fc27c5437dcc</a></p>



<a name="182236811"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182236811" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182236811">(Nov 30 2019 at 12:06)</a>:</h4>
<p><span class="user-mention" data-user-id="124069">@Alexander Regueiro</span> you can get rid of the intrinsic by putting the DebugEverything trait in your generated file (or injecting a dependency on a crate that implements it, not sure whether the current REPL can import crates)</p>



<a name="182243137"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182243137" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182243137">(Nov 30 2019 at 15:23)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> yeah, that's not bad, but the thing is a) I don't want to depend on nightly, b) I still want a way to "hand back" string values to the REPL itself, so some sort of intrinsic would be neded for that.</p>



<a name="182243347"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182243347" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182243347">(Nov 30 2019 at 15:29)</a>:</h4>
<p>Not sure why b) would be affected?</p>



<a name="182243413"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182243413" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182243413">(Nov 30 2019 at 15:31)</a>:</h4>
<p>Right now you get a <code>*const dyn Debug</code>, with this you'd get a <code>&amp;dyn DebugEverything</code>. In both cases you have to call the fmt method</p>



<a name="182243468"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182243468" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182243468">(Nov 30 2019 at 15:33)</a>:</h4>
<p>Wrt a) are you worried the specialization feature gate will break/disappear?</p>



<a name="182243535"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182243535" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182243535">(Nov 30 2019 at 15:34)</a>:</h4>
<p>no, I just want people to be able to use the REPL without nightly. so they can specify the version/toolchain, ideally. :-)</p>



<a name="182243552"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182243552" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182243552">(Nov 30 2019 at 15:35)</a>:</h4>
<p>b) because I don't want to just print from <em>within</em> the evaluated code, but also hand back strings to the REPL, so it can use them as it pleases (maybe just format and then print them according to settings, maybe something fancY)</p>



<a name="182245956"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182245956" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182245956">(Nov 30 2019 at 16:41)</a>:</h4>
<p>I understand what you're saying wrt b), but the intrinsic doesn't give any string to the REPL</p>



<a name="182246006"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182246006" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182246006">(Nov 30 2019 at 16:42)</a>:</h4>
<p>since you're calling the intrinsic, you're forever stuck on nightly anyway</p>



<a name="182246074"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182246074" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182246074">(Nov 30 2019 at 16:44)</a>:</h4>
<p>activating a feature gate for an intrinsic or for a feature makes no difference as far as i can tell</p>



<a name="182246171"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182246171" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182246171">(Nov 30 2019 at 16:47)</a>:</h4>
<p>wrt b) I think I'm missing some information, thus don't get what the difference between <code>as_debug(&amp;value)</code> and <code>value as *DebugEverything</code> is (except for the None result, but that is resolved by the default impl)</p>



<a name="182246176"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182246176" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182246176">(Nov 30 2019 at 16:47)</a>:</h4>
<p>Or maybe you're thinking about future changes?</p>



<a name="182249014"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182249014" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182249014">(Nov 30 2019 at 18:03)</a>:</h4>
<p>Making it work on stable should be possible by using hygiene to pretend that the respective code came from a macro which allowed the necessary feature gates, like:</p>
<p><a href="https://github.com/rust-lang/rust/blob/d8bdb3fdcbd88eb16e1a6669236122c41ed2aed3/src/libstd/thread/local.rs#L127" target="_blank" title="https://github.com/rust-lang/rust/blob/d8bdb3fdcbd88eb16e1a6669236122c41ed2aed3/src/libstd/thread/local.rs#L127">https://github.com/rust-lang/rust/blob/d8bdb3fdcbd88eb16e1a6669236122c41ed2aed3/src/libstd/thread/local.rs#L127</a></p>



<a name="182249470"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182249470" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182249470">(Nov 30 2019 at 18:15)</a>:</h4>
<p>the use of that attribute also requires feature gates, so you don't gain anything (unless we put it in libcore and stabilize it, which we won't do for an internal thing)</p>



<a name="182250158"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182250158" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182250158">(Nov 30 2019 at 18:35)</a>:</h4>
<p>I meant that the REPL changes the parsed syntax so that it looks like it came from a macro with that attribute.</p>



<a name="182250205"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182250205" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182250205">(Nov 30 2019 at 18:36)</a>:</h4>
<p>right, but that applies to either solution <span aria-label="slight smile" class="emoji emoji-1f642" role="img" title="slight smile">:slight_smile:</span></p>



<a name="182254850"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182254850" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182254850">(Nov 30 2019 at 20:53)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> yeah, I forgot about that, oops. I still very a little uneasy about the specialisation-based approach... I remember discussing this with <span class="user-mention" data-user-id="126931">@centril</span> (he implemented something similar to <code>DebugEverything</code> trait?) and deciding it couldn't work properly, but I forget why exactly... perhaps I was mistaken.</p>



<a name="182254900"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182254900" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182254900">(Nov 30 2019 at 20:54)</a>:</h4>
<p>as for b), the point is that it's nice to have an intrinsic for being able to pass some string value to the Miri evaluator.</p>



<a name="182254902"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182254902" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182254902">(Nov 30 2019 at 20:54)</a>:</h4>
<p>which would be different from <code>as_debug</code>, sure.</p>



<a name="182254907"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182254907" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182254907">(Nov 30 2019 at 20:54)</a>:</h4>
<p>(it could be part of the same intrinsic, or a separate one, rather)</p>



<a name="182255191"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182255191" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182255191">(Nov 30 2019 at 21:02)</a>:</h4>
<p>I'm not sure if this is what Centril found, but specialization on traits (as implemented by rustc) is unsound and this can even be exploited by downstream crates without the feature.</p>



<a name="182255281"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182255281" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182255281">(Nov 30 2019 at 21:05)</a>:</h4>
<p>I don't think that your intrinsic avoids this problem though.</p>



<a name="182255344"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182255344" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182255344">(Nov 30 2019 at 21:07)</a>:</h4>
<p>aha</p>



<a name="182255348"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182255348" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182255348">(Nov 30 2019 at 21:07)</a>:</h4>
<p>probably not, but that's a fair point too</p>



<a name="182255392"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182255392" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182255392">(Nov 30 2019 at 21:08)</a>:</h4>
<p><span class="user-mention" data-user-id="116118">@Matthew Jasper</span> what's the problem with the intrinsic, as you see it?</p>



<a name="182255478"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182255478" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182255478">(Nov 30 2019 at 21:10)</a>:</h4>
<p>It would probably need to do something similar to generator witnesses, where all of the regions are replaced with regions that are bound by the binder around the predicate.</p>



<a name="182255489"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182255489" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182255489">(Nov 30 2019 at 21:10)</a>:</h4>
<p>The issue is that it's only checking that there are some lifetimes where the predicate holds.</p>



<a name="182255502"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182255502" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182255502">(Nov 30 2019 at 21:11)</a>:</h4>
<p>Maybe the unusual nature of the repl works around this somehow.</p>



<a name="182257315"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182257315" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182257315">(Nov 30 2019 at 21:52)</a>:</h4>
<p>hmm</p>



<a name="182257343"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182257343" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182257343">(Nov 30 2019 at 21:53)</a>:</h4>
<p><span class="user-mention" data-user-id="116118">@Matthew Jasper</span> yes possibly.</p>



<a name="182257344"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182257344" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182257344">(Nov 30 2019 at 21:53)</a>:</h4>
<p>how would this look in code?</p>



<a name="182257432"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182257432" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182257432">(Nov 30 2019 at 21:54)</a>:</h4>
<p><code>impl Debug for A&lt;'static&gt; { /* impl that requires 'static */ }</code> and then debug printing an <code>A&lt;'short&gt;</code></p>



<a name="182257466"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182257466" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182257466">(Nov 30 2019 at 21:55)</a>:</h4>
<p>It's fairly fiddly to create a use after free from this.</p>



<a name="182257534"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182257534" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182257534">(Nov 30 2019 at 21:57)</a>:</h4>
<p>A could contain a stack reference and the Debug impl could store it in a static.</p>



<a name="182257543"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182257543" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182257543">(Nov 30 2019 at 21:57)</a>:</h4>
<p>That way a dangling reference is made</p>



<a name="182258454"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182258454" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182258454">(Nov 30 2019 at 22:26)</a>:</h4>
<p>The main reason I like the specialization approach over the intrinsic is that it's much easier to grok the Rust code than the rustc code emulating it</p>



<a name="182258461"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182258461" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182258461">(Nov 30 2019 at 22:26)</a>:</h4>
<p>the unsoundness is irrelevant for this use case, miri won't allow you to do anything stupid</p>



<a name="182258472"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182258472" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182258472">(Nov 30 2019 at 22:27)</a>:</h4>
<p>so even if you build an impl that leaks a local value, once it's deallocated and you try to use it you'll get an error</p>



<a name="182258474"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182258474" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182258474">(Nov 30 2019 at 22:27)</a>:</h4>
<p>even without stacked borrows</p>



<a name="182258528"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182258528" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182258528">(Nov 30 2019 at 22:29)</a>:</h4>
<p>there's also no need for an intrinsic for the "give a value back to the repl", because you can just define an arbitrary <code>extern "C"</code> function with a name noone will use and hook that</p>



<a name="182258531"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182258531" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182258531">(Nov 30 2019 at 22:29)</a>:</h4>
<p>no need for rustc to know about it</p>



<a name="182258811"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182258811" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182258811">(Nov 30 2019 at 22:39)</a>:</h4>
<p>I suppose so.</p>



<a name="182258812"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182258812" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182258812">(Nov 30 2019 at 22:39)</a>:</h4>
<p>An intrinsic seems somehow "neater" though...</p>



<a name="182258814"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182258814" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182258814">(Nov 30 2019 at 22:39)</a>:</h4>
<p>arguably less hacky?</p>



<a name="182258920"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182258920" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182258920">(Nov 30 2019 at 22:42)</a>:</h4>
<p>not hackier than miri supporting <code>puts</code></p>



<a name="182259966"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182259966" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182259966">(Nov 30 2019 at 23:20)</a>:</h4>
<p>heh</p>



<a name="182259971"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182259971" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182259971">(Nov 30 2019 at 23:21)</a>:</h4>
<p>I suppose. It just feels semantically like it should be an intrinsic... hmm.</p>



<a name="182259974"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182259974" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182259974">(Nov 30 2019 at 23:21)</a>:</h4>
<p>Let me ponder it a bit.</p>



<a name="182412633"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182412633" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182412633">(Dec 03 2019 at 03:17)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> Can't say I've changed my mind about it being hacky... but I do see why you might be drawn to this, since it requires no rustc changes (not that the rustc changes would be anything but tiny). As for <code>puts</code>, I consider that a bit different, since it's <em>meant</em> to be a C stdlib fn that is normally called via the C ABI. But miri wouldn' t be emulating a C fn / ABI call here. It's very much something that only makes sense to use within the REPL. :-)</p>



<a name="182422069"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182422069" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182422069">(Dec 03 2019 at 07:13)</a>:</h4>
<p>There's another advntage of it not being in rustc: modifying its API does not require you to touch rustc, giving you more freedom</p>



<a name="182466571"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182466571" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182466571">(Dec 03 2019 at 16:26)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> That's true actually... I mean, making a PR to rustc is pretty easy, but you have a fair point.</p>



<a name="182466592"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182466592" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182466592">(Dec 03 2019 at 16:26)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> can the fn just be "extern" and not "extern C", in fact?</p>



<a name="182467321"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182467321" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182467321">(Dec 03 2019 at 16:32)</a>:</h4>
<blockquote>
<p><code>impl Debug for A&lt;'static&gt; { /* impl that requires 'static */ }</code> and then debug printing an <code>A&lt;'short&gt;</code></p>
</blockquote>
<p>Maybe replace all <code>ReErased</code> with fresh lifetimes? I think that will require the <code>Debug</code> impl to be valid for all lifetimes, thus fixing the unsoundness.</p>



<a name="182467896"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182467896" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182467896">(Dec 03 2019 at 16:37)</a>:</h4>
<p>I prefer <code>as_debug</code> to be an intrinsic, as all functions handled specially by both cg_llvm and cg_clif are either lang items or intrinsics. Miri does handle some <code>extern "C"</code> functions specially, but those don't perform magic, but are only shims. If the code wasn't running in an interpreter, those functions could be implemented without the help of the compiler. <code>as_debug</code> however is magic, as it inspects if a type implements <code>Debug</code>.</p>



<a name="182472114"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182472114" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182472114">(Dec 03 2019 at 17:16)</a>:</h4>
<blockquote>
<p><span class="user-mention silent" data-user-id="124288">oli</span> can the fn just be "extern" and not "extern C", in fact?</p>
</blockquote>
<p>yes, it does not have to be <code>"C"</code>, but that makes it easier to use from miri</p>



<a name="182473081"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182473081" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182473081">(Dec 03 2019 at 17:24)</a>:</h4>
<p>hmm, okay. makes it easier because the ABI is simpler? Miri can surely use the Rust ABI though?</p>



<a name="182473339"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182473339" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182473339">(Dec 03 2019 at 17:25)</a>:</h4>
<p>sure, but you need to shim it. Most of the time that is totally not a problem though.</p>



<a name="182473400"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182473400" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182473400">(Dec 03 2019 at 17:26)</a>:</h4>
<p>and for your REPL you are right, you are in control anyway, so you can just us the Rust ABI</p>



<a name="182474043"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182474043" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182474043">(Dec 03 2019 at 17:31)</a>:</h4>
<p>cool</p>



<a name="182474049"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182474049" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182474049">(Dec 03 2019 at 17:31)</a>:</h4>
<p>okay, you've won me over</p>



<a name="182474051"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182474051" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182474051">(Dec 03 2019 at 17:31)</a>:</h4>
<p>let's do that.</p>



<a name="182474249"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20dyn%20Debug%20intrinsic/near/182474249" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20dyn.20Debug.20intrinsic.html#182474249">(Dec 03 2019 at 17:33)</a>:</h4>
<p>(unless anyone else has objections...)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>